package com.huaao.micropolice.root.freemarker;
import java.io.StringWriter;
import java.util.Map;

import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import freemarker.template.Configuration;
import freemarker.template.Template;

public class FreemarkerTemplate {
	
	public static String process(String templateName, Map<String, Object> rootMap , FreeMarkerConfigurer freeMarkerConfigurer)throws Exception {
	   Configuration configuration = freeMarkerConfigurer.getConfiguration();
	   Template template = configuration.getTemplate(templateName);
	   StringWriter stringWriter=new StringWriter();
	   template.process(rootMap, stringWriter);
	   return stringWriter.toString();
	}
}